Update to rust master
authorAlex Crichton <alex@alexcrichton.com>
Fri, 6 Feb 2015 07:27:53 +0000 (23:27 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Fri, 6 Feb 2015 23:10:05 +0000 (15:10 -0800)
36 files changed:
Cargo.lock
src/bin/bench.rs
src/bin/cargo.rs
src/bin/run.rs
src/bin/test.rs
src/cargo/lib.rs
src/cargo/ops/cargo_new.rs
src/cargo/ops/cargo_package.rs
src/cargo/ops/cargo_run.rs
src/cargo/ops/cargo_rustc/compilation.rs
src/cargo/ops/cargo_rustc/engine.rs
src/cargo/ops/cargo_rustc/mod.rs
src/cargo/ops/cargo_test.rs
src/cargo/ops/registry.rs
src/cargo/util/config.rs
src/cargo/util/errors.rs
src/cargo/util/important_paths.rs
src/cargo/util/paths.rs
src/cargo/util/process_builder.rs
src/cargo/util/profile.rs
src/cargo/util/toml.rs
src/rustversion.txt
tests/support/mod.rs
tests/support/paths.rs
tests/test_cargo.rs
tests/test_cargo_bench.rs
tests/test_cargo_build_lib.rs
tests/test_cargo_compile.rs
tests/test_cargo_compile_custom_build.rs
tests/test_cargo_compile_plugins.rs
tests/test_cargo_cross_compile.rs
tests/test_cargo_new.rs
tests/test_cargo_profiles.rs
tests/test_cargo_run.rs
tests/test_cargo_test.rs
tests/tests.rs

index 0248908a7a9d92b10595028ba0cf6535373988d0..e9034f5f1995e6fbb593bf308dfc3dc0015a042e 100644 (file)
@@ -2,33 +2,33 @@
 name = "cargo"
 version = "0.1.0"
 dependencies = [
- "advapi32-sys 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "curl 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
- "docopt 0.6.34 (registry+https://github.com/rust-lang/crates.io-index)",
+ "advapi32-sys 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "curl 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
+ "docopt 0.6.35 (registry+https://github.com/rust-lang/crates.io-index)",
  "env_logger 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "flate2 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "git2 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
- "glob 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "flate2 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "git2 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
+ "glob 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
  "hamcrest 0.1.0 (git+https://github.com/carllerche/hamcrest-rust.git)",
  "log 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "regex 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
  "registry 0.1.0",
- "rustc-serialize 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
  "semver 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
  "tar 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
  "term 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
  "time 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
  "toml 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
- "url 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "url 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "advapi32-sys"
-version = "0.0.2"
+version = "0.0.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "winapi 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -38,13 +38,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "curl"
-version = "0.1.13"
+version = "0.1.14"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "curl-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "openssl-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "url 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
+ "url 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -60,11 +60,11 @@ dependencies = [
 
 [[package]]
 name = "docopt"
-version = "0.6.34"
+version = "0.6.35"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "regex 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -78,11 +78,11 @@ dependencies = [
 
 [[package]]
 name = "flate2"
-version = "0.1.7"
+version = "0.1.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "libc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "miniz-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "miniz-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -92,17 +92,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "git2"
-version = "0.1.13"
+version = "0.1.15"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "bitflags 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "libgit2-sys 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
- "url 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libgit2-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
+ "url 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "glob"
-version = "0.1.8"
+version = "0.1.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
@@ -115,7 +115,7 @@ name = "kernel32-sys"
 version = "0.0.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "winapi 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -125,7 +125,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "libgit2-sys"
-version = "0.1.11"
+version = "0.1.12"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "libssh2-sys 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -172,10 +172,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "miniz-sys"
-version = "0.1.1"
+version = "0.1.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "gcc 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -206,13 +207,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 name = "registry"
 version = "0.1.0"
 dependencies = [
- "curl 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "curl 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "rustc-serialize"
-version = "0.2.11"
+version = "0.2.12"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
@@ -232,7 +233,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "kernel32-sys 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -249,20 +250,20 @@ name = "toml"
 version = "0.1.16"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "rustc-serialize 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "url"
-version = "0.2.18"
+version = "0.2.19"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "winapi"
-version = "0.1.8"
+version = "0.1.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
index d057c3626c899ca17568de5aee9a2ec10c22b4f1..99fa48eb06a8ebec753b1ffa0b34e6c84da96f3f 100644 (file)
@@ -77,7 +77,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
         None => Ok(None),
         Some(err) => {
             Err(match err.exit {
-                Some(ExitStatus(i)) => CliError::new("", i as u32),
+                Some(ExitStatus(i)) => CliError::new("", i as i32),
                 _ => CliError::from_boxed(box Human(err), 101)
             })
         }
index 60b0b9b47623fae6475b879a660b7896dfe73050..95ebc1c2bbd5dcd97f36b4348f46640974217498 100644 (file)
@@ -1,15 +1,15 @@
-#![feature(collections, core, io, os, path)]
+#![feature(collections, core, io, path, env)]
 
 extern crate "rustc-serialize" as rustc_serialize;
 extern crate cargo;
-#[macro_use] extern crate log;
 extern crate env_logger;
+#[macro_use] extern crate log;
 
 use std::collections::BTreeSet;
-use std::os;
-use std::old_io;
+use std::env;
 use std::old_io::fs::{self, PathExtensions};
 use std::old_io::process::{Command,InheritFd,ExitStatus,ExitSignal};
+use std::old_io;
 
 use cargo::{execute_main_without_stdin, handle_error, shell};
 use cargo::core::MultiShell;
@@ -86,7 +86,6 @@ macro_rules! each_subcommand{ ($mac:ident) => ({
   on this top-level information.
 */
 fn execute(flags: Flags, config: &Config) -> CliResult<Option<()>> {
-    debug!("executing; cmd=cargo; args={:?}", os::args());
     config.shell().set_verbose(flags.flag_verbose);
 
     if flags.flag_list {
@@ -100,7 +99,7 @@ fn execute(flags: Flags, config: &Config) -> CliResult<Option<()>> {
     let (mut args, command) = match flags.arg_command.as_slice() {
         "" | "help" if flags.arg_args.len() == 0 => {
             config.shell().set_verbose(true);
-            let args = &[os::args()[0].clone(), "-h".to_string()];
+            let args = &["foo".to_string(), "-h".to_string()];
             let r = cargo::call_main_without_stdin(execute, config, USAGE, args,
                                                    false);
             cargo::process_executed(r, &mut **config.shell());
@@ -113,7 +112,7 @@ fn execute(flags: Flags, config: &Config) -> CliResult<Option<()>> {
         s => (flags.arg_args.clone(), s),
     };
     args.insert(0, command.to_string());
-    args.insert(0, os::args()[0].clone());
+    args.insert(0, "foo".to_string());
 
     macro_rules! cmd{ ($name:ident) => (
         if command.as_slice() == stringify!($name).replace("_", "-").as_slice() {
@@ -136,8 +135,9 @@ fn execute(flags: Flags, config: &Config) -> CliResult<Option<()>> {
 
 fn find_closest(cmd: &str) -> Option<String> {
     match list_commands().iter()
-                            // doing it this way (instead of just .min_by(|c| c.lev_distance(cmd)))
-                            // allows us to only make suggestions that have an edit distance of
+                            // doing it this way (instead of just .min_by(|c|
+                            // c.lev_distance(cmd))) allows us to only make
+                            // suggestions that have an edit distance of
                             // 3 or less
                             .map(|c| (lev_distance(c.as_slice(), cmd), c))
                             .filter(|&(d, _): &(usize, &String)| d < 4)
@@ -171,11 +171,11 @@ fn execute_subcommand(cmd: &str, args: &[String], shell: &mut MultiShell) {
     match status {
         Ok(ExitStatus(0)) => (),
         Ok(ExitStatus(i)) => {
-            handle_error(CliError::new("", i as u32), shell)
+            handle_error(CliError::new("", i as i32), shell)
         }
         Ok(ExitSignal(i)) => {
             let msg = format!("subcommand failed with signal: {}", i);
-            handle_error(CliError::new(msg, i as u32), shell)
+            handle_error(CliError::new(msg, i as i32), shell)
         }
         Err(old_io::IoError{kind, ..}) if kind == old_io::FileNotFound =>
             handle_error(CliError::new("No such subcommand", 127), shell),
@@ -202,11 +202,11 @@ fn list_commands() -> BTreeSet<String> {
                 _ => continue
             };
             if filename.starts_with(command_prefix) &&
-                    filename.ends_with(os::consts::EXE_SUFFIX) &&
+                    filename.ends_with(env::consts::EXE_SUFFIX) &&
                     is_executable(entry) {
                 let command = &filename[
                     command_prefix.len()..
-                    filename.len() - os::consts::EXE_SUFFIX.len()];
+                    filename.len() - env::consts::EXE_SUFFIX.len()];
                 commands.insert(String::from_str(command));
             }
         }
@@ -229,7 +229,7 @@ fn is_executable(path: &Path) -> bool {
 
 /// Get `Command` to run given command.
 fn find_command(cmd: &str) -> Option<Path> {
-    let command_exe = format!("cargo-{}{}", cmd, os::consts::EXE_SUFFIX);
+    let command_exe = format!("cargo-{}{}", cmd, env::consts::EXE_SUFFIX);
     let dirs = list_command_directory();
     let mut command_paths = dirs.iter().map(|dir| dir.join(command_exe.as_slice()));
     command_paths.find(|path| path.exists())
@@ -238,20 +238,13 @@ fn find_command(cmd: &str) -> Option<Path> {
 /// List candidate locations where subcommands might be installed.
 fn list_command_directory() -> Vec<Path> {
     let mut dirs = vec![];
-    match os::self_exe_path() {
-        Some(path) => {
-            dirs.push(path.join("../lib/cargo"));
-            dirs.push(path);
-        },
-        None => {}
-    };
-    match std::os::getenv("PATH") {
-        Some(val) => {
-            for dir in os::split_paths(val).iter() {
-                dirs.push(Path::new(dir))
-            }
-        },
-        None => {}
-    };
+    if let Ok(mut path) = env::current_exe() {
+        path.pop();
+        dirs.push(path.join("../lib/cargo"));
+        dirs.push(path);
+    }
+    if let Some(val) = env::var("PATH") {
+        dirs.extend(env::split_paths(&val));
+    }
     dirs
 }
index 272c1c830f9fb074157773749a541826ad7101cc..da295a4cc7bc63c83a1189373adb743ef69e20be 100644 (file)
@@ -87,7 +87,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
         None => Ok(None),
         Some(err) => {
             Err(match err.exit {
-                Some(ExitStatus(i)) => CliError::from_boxed(box err, i as u32),
+                Some(ExitStatus(i)) => CliError::from_boxed(box err, i as i32),
                 _ => CliError::from_boxed(box err, 101),
             })
         }
index 3d39d7f8ff713f4cfcceb7defbaf049b3d98bec1..1e27d4465b45854b521719f394a154745e63534c 100644 (file)
@@ -79,7 +79,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
         None => Ok(None),
         Some(err) => {
             Err(match err.exit {
-                Some(ExitStatus(i)) => CliError::new("", i as u32),
+                Some(ExitStatus(i)) => CliError::new("", i as i32),
                 _ => CliError::from_boxed(box Human(err), 101)
             })
         }
index 28b2696ae57b1e01a01506572cd300019162cd2b..9e2e0f85f41d2cc3c6e3144b1446ec1b2ddc5242 100644 (file)
@@ -1,5 +1,5 @@
 #![deny(unused)]
-#![feature(collections, core, hash, io, libc, os, path, std_misc, unicode)]
+#![feature(collections, hash, io, libc, os, path, std_misc, unicode, env, core)]
 #![cfg_attr(test, deny(warnings))]
 
 extern crate libc;
@@ -22,10 +22,10 @@ extern crate url;
 
 extern crate registry;
 
+use std::env;
 use std::error::Error;
 use std::old_io::stdio::{stdout_raw, stderr_raw};
 use std::old_io::{self, stdout, stderr};
-use std::os;
 use rustc_serialize::{Decodable, Encodable};
 use rustc_serialize::json::{self, Json};
 use docopt::Docopt;
@@ -33,7 +33,7 @@ use docopt::Docopt;
 use core::{Shell, MultiShell, ShellConfig};
 use term::color::{BLACK, RED};
 
-pub use util::{CargoError, CliError, CliResult, human, Config};
+pub use util::{CargoError, CliError, CliResult, human, Config, ChainError};
 
 pub mod core;
 pub mod ops;
@@ -93,12 +93,15 @@ fn process<V, F>(mut callback: F)
           V: Encodable
 {
     let mut shell = shell(true);
-    process_executed({
-        match Config::new(&mut shell) {
-            Ok(cfg) => callback(os::args().as_slice(), &cfg),
-            Err(e) => Err(CliError::from_boxed(e, 101)),
-        }
-    }, &mut shell)
+    process_executed((|| {
+        let config = try!(Config::new(&mut shell));
+        let args: Vec<_> = try!(env::args().map(|s| {
+            s.into_string().map_err(|s| {
+                human(format!("invalid unicode in argument: {:?}", s))
+            })
+        }).collect());
+        callback(&args, &config)
+    })(), &mut shell)
 }
 
 pub fn process_executed<T>(result: CliResult<Option<T>>, shell: &mut MultiShell)
@@ -158,7 +161,7 @@ pub fn handle_error(err: CliError, shell: &mut MultiShell) {
                                  with --verbose.".to_string(), BLACK);
     }
 
-    std::os::set_exit_status(exit_code as isize);
+    std::env::set_exit_status(exit_code);
 }
 
 fn handle_cause(mut cargo_err: &CargoError, shell: &mut MultiShell) -> bool {
index 85ab012c7b69ffb4aac9d4a0c7daf63178064e85..a2bafbc34cf2e3602b1e7e87704f8358c71d3cca 100644 (file)
@@ -1,6 +1,6 @@
-use std::os;
-use std::old_io::{self, fs, File};
+use std::env;
 use std::old_io::fs::PathExtensions;
+use std::old_io::{self, fs, File};
 
 use rustc_serialize::{Decodable, Decoder};
 
@@ -134,8 +134,8 @@ fn discover_author() -> CargoResult<(String, Option<String>)> {
     let git_config = git_config.as_ref();
     let name = git_config.and_then(|g| g.get_str("user.name").ok())
                          .map(|s| s.to_string())
-                         .or_else(|| os::getenv("USER"))      // unix
-                         .or_else(|| os::getenv("USERNAME")); // windows
+                         .or_else(|| env::var_string("USER").ok())      // unix
+                         .or_else(|| env::var_string("USERNAME").ok()); // windows
     let name = match name {
         Some(name) => name,
         None => {
index 1a75d9c2da299794d64fdf18b68f1907d644502c..07d83e038ea473303ce36dada1412b4ff29f4811 100644 (file)
@@ -1,6 +1,6 @@
 use std::old_io::{fs, File, USER_DIR};
 use std::old_io::fs::PathExtensions;
-use std::path;
+use std::old_path;
 
 use tar::Archive;
 use flate2::{GzBuilder, BestCompression};
@@ -133,7 +133,7 @@ fn tar(pkg: &Package, src: &PathSource, config: &Config,
             shell.status("Archiving", relative.as_slice())
         }));
         let path = format!("{}-{}{}{}", pkg.get_name(),
-                           pkg.get_version(), path::SEP, relative);
+                           pkg.get_version(), old_path::SEP, relative);
         try!(ar.append(path.as_slice(), &mut file).chain_error(|| {
             internal(format!("could not archive source file `{}`", relative))
         }));
index 0ef3986a9f1ff26364958cda266dde918fe19263..883b7f0a442e53b61f024d3ef0f0d4714e075a18 100644 (file)
@@ -1,4 +1,3 @@
-use std::os;
 
 use ops::{self, ExecEngine};
 use util::{CargoResult, human, process, ProcessError, ChainError};
@@ -48,14 +47,14 @@ pub fn run(manifest_path: &Path,
         (None, true) => dst.join("examples").join(bin.get_name()),
         (None, false) => dst.join(bin.get_name()),
     };
-    let exe = match exe.path_relative_from(&try!(os::getcwd())) {
+    let exe = match exe.path_relative_from(config.cwd()) {
         Some(path) => path,
         None => exe,
     };
     let process = try!(try!(compile.target_process(exe, &root))
                               .into_process_builder())
                               .args(args)
-                              .cwd(try!(os::getcwd()));
+                              .cwd(config.cwd().clone());
 
     try!(config.shell().status("Running", process.to_string()));
     Ok(process.exec().err())
index 5750924c2781ff387348df326d5f8d714b392d02..3a220cfc4ea1f7a7d89a90bfc44a8f1fdd764688 100644 (file)
@@ -1,7 +1,7 @@
 use std::collections::HashMap;
 use std::dynamic_lib::DynamicLibrary;
 use std::ffi::CString;
-use std::path::BytesContainer;
+use std::old_path::BytesContainer;
 use semver::Version;
 
 use core::{PackageId, Package};
index e3ca33a644db504ab85e96d17d77c975c7144549..9998e0e7bd8cfbe96bdff9bc984c54af032ba488 100644 (file)
@@ -1,9 +1,9 @@
 use std::collections::HashMap;
+use std::env;
 use std::ffi::CString;
 use std::fmt::{self, Formatter};
 use std::old_io::process::ProcessOutput;
-use std::os;
-use std::path::BytesContainer;
+use std::old_path::BytesContainer;
 
 use util::{self, CargoResult, ProcessError, ProcessBuilder};
 
@@ -39,13 +39,11 @@ pub struct CommandPrototype {
 
 impl CommandPrototype {
     pub fn new(ty: CommandType) -> CargoResult<CommandPrototype> {
-        use std::os;
-
         Ok(CommandPrototype {
             ty: ty,
             args: Vec::new(),
             env: HashMap::new(),
-            cwd: try!(os::getcwd()),
+            cwd: try!(env::current_dir()),
         })
     }
 
@@ -87,7 +85,7 @@ impl CommandPrototype {
 
     pub fn get_env(&self, var: &str) -> Option<CString> {
         self.env.get(var).cloned().or_else(|| {
-            Some(os::getenv(var).map(|s| CString::from_vec(s.into_bytes())))
+            Some(env::var_string(var).ok().map(|s| CString::from_vec(s.into_bytes())))
         }).and_then(|val| val)
     }
 
index 0e81545b790ae6c83b4ceabfbbd45ea8bdab07f4..e10363ddb01d6d5a9da63b9dc5d36c63f162106e 100644 (file)
@@ -3,7 +3,7 @@ use std::dynamic_lib::DynamicLibrary;
 use std::ffi::CString;
 use std::old_io::fs::{self, PathExtensions};
 use std::os;
-use std::path;
+use std::old_path;
 use std::sync::Arc;
 
 use core::{SourceMap, Package, PackageId, PackageSet, Target, Resolve};
@@ -455,6 +455,7 @@ fn crawl_build_deps<'a>(cx: &'a Context, pkg: &'a Package,
 // For all plugin dependencies, add their -L paths (now calculated and
 // present in `state`) to the dynamic library load path for the command to
 // execute.
+#[allow(deprecated)] // need an OsStr based Command
 fn add_plugin_deps(rustc: CommandPrototype,
                    build_state: &BuildMap,
                    plugin_deps: Vec<PackageId>)
@@ -726,7 +727,7 @@ fn build_deps_args(mut cmd: CommandPrototype, target: &Target, package: &Package
             v.push_all(target.get_name().as_bytes());
             v.push(b'=');
             v.push_all(layout.root().as_vec());
-            v.push(path::SEP_BYTE);
+            v.push(old_path::SEP_BYTE);
             v.push_all(filename.as_bytes());
             cmd = cmd.arg("--extern").arg(v.as_slice());
         }
index 2355d13bdfbe6878dd9aca742cf25eb45db6825c..6560d5503b1ea79a9b0d9d003e3af519b79edc5b 100644 (file)
@@ -1,4 +1,3 @@
-use std::os;
 
 use core::Source;
 use sources::PathSource;
@@ -28,7 +27,7 @@ pub fn run_tests(manifest_path: &Path,
         target_name.map_or(true, |target_name| target_name == test_name.as_slice())
     });
 
-    let cwd = try!(os::getcwd());
+    let cwd = config.cwd();
     for &(_, ref exe) in tests_to_run {
         let to_display = match exe.path_relative_from(&cwd) {
             Some(path) => path,
index 60f2f9202f98efa4fff9ee523470111dbeac1a55..a338eaabf3ee41d1ac7f7440c217cfeb68385860 100644 (file)
@@ -1,8 +1,8 @@
 use std::collections::HashMap;
+use std::env;
+use std::iter::repeat;
 use std::old_io::File;
 use std::old_io::fs::PathExtensions;
-use std::iter::repeat;
-use std::os;
 
 use curl::http;
 use git2;
@@ -191,7 +191,7 @@ pub fn http_proxy(config: &Config) -> CargoResult<Option<String>> {
         }
         Err(..) => {}
     }
-    Ok(os::getenv("HTTP_PROXY"))
+    Ok(env::var_string("HTTP_PROXY").ok())
 }
 
 pub fn http_timeout(config: &Config) -> CargoResult<Option<i64>> {
@@ -199,13 +199,13 @@ pub fn http_timeout(config: &Config) -> CargoResult<Option<i64>> {
         Some((s, _)) => return Ok(Some(s)),
         None => {}
     }
-    Ok(os::getenv("HTTP_TIMEOUT").and_then(|s| s.parse().ok()))
+    Ok(env::var_string("HTTP_TIMEOUT").ok().and_then(|s| s.parse().ok()))
 }
 
 pub fn registry_login(config: &Config, token: String) -> CargoResult<()> {
     let RegistryConfig { index, token: _ } = try!(registry_configuration(config));
     let mut map = HashMap::new();
-    let p = try!(os::getcwd());
+    let p = config.cwd().clone();
     match index {
         Some(index) => {
             map.insert("index".to_string(), ConfigValue::String(index, p.clone()));
index 5f58001400435daa0fad408c2bab9f6e23c94063..dba02d56517630d2945eac49c6a6272b87ee85f4 100644 (file)
@@ -1,9 +1,11 @@
-use std::{fmt, os, mem};
 use std::cell::{RefCell, RefMut, Ref, Cell};
-use std::collections::hash_map::{HashMap};
 use std::collections::hash_map::Entry::{Occupied, Vacant};
-use std::old_io;
+use std::collections::hash_map::{HashMap};
+use std::env;
+use std::fmt;
+use std::mem;
 use std::old_io::fs::{self, PathExtensions, File};
+use std::old_io;
 
 use rustc_serialize::{Encodable,Encoder};
 use toml;
@@ -28,7 +30,7 @@ pub struct Config<'a> {
 
 impl<'a> Config<'a> {
     pub fn new(shell: &'a mut MultiShell) -> CargoResult<Config<'a>> {
-        let cwd = try!(os::getcwd().chain_error(|| {
+        let cwd = try!(env::current_dir().chain_error(|| {
             human("couldn't get the current directory of the process")
         }));
         let (rustc_version, rustc_host) = try!(ops::rustc_version());
@@ -383,8 +385,8 @@ impl ConfigValue {
 }
 
 fn homedir() -> Option<Path> {
-    let cargo_home = os::getenv("CARGO_HOME").map(|p| Path::new(p));
-    let user_home = os::homedir().map(|p| p.join(".cargo"));
+    let cargo_home = env::var_string("CARGO_HOME").map(|p| Path::new(p)).ok();
+    let user_home = env::home_dir().map(|p| p.join(".cargo"));
     return cargo_home.or(user_home);
 }
 
index 0a528f9ed893674db29c982dfae305df4ae9e5f8..ff5c0add9ed3e7ad0bfeb7987a3ef2b1e7d02486 100644 (file)
@@ -193,7 +193,7 @@ pub type CliResult<T> = Result<T, CliError>;
 pub struct CliError {
     pub error: Box<CargoError>,
     pub unknown: bool,
-    pub exit_code: u32
+    pub exit_code: i32
 }
 
 impl Error for CliError {
@@ -208,22 +208,28 @@ impl fmt::Display for CliError {
 }
 
 impl CliError {
-    pub fn new<S: Str>(error: S, code: u32) -> CliError {
+    pub fn new<S: Str>(error: S, code: i32) -> CliError {
         let error = human(error.as_slice().to_string());
         CliError::from_boxed(error, code)
     }
 
-    pub fn from_error<E: CargoError + 'static>(error: E, code: u32) -> CliError {
+    pub fn from_error<E: CargoError + 'static>(error: E, code: i32) -> CliError {
         let error = Box::new(error) as Box<CargoError>;
         CliError::from_boxed(error, code)
     }
 
-    pub fn from_boxed(error: Box<CargoError>, code: u32) -> CliError {
+    pub fn from_boxed(error: Box<CargoError>, code: i32) -> CliError {
         let human = error.is_human();
         CliError { error: error, exit_code: code, unknown: !human }
     }
 }
 
+impl FromError<Box<CargoError>> for CliError {
+    fn from_error(err: Box<CargoError>) -> CliError {
+        CliError::from_boxed(err, 101)
+    }
+}
+
 // =============================================================================
 // various impls
 
index 4ba23b36fcb226069c204a362fd47eb33c4ceea4..7cc74d9d5439f416906c6a386f38b16bfb111594 100644 (file)
@@ -1,16 +1,15 @@
-use std::os;
+use std::env;
 use std::old_io::fs::PathExtensions;
-use util::{CargoResult, CliError, CliResult, human};
+use util::{CargoResult, human, ChainError};
 
 /// Iteratively search for `file` in `pwd` and its parents, returning
 /// the path of the directory.
 pub fn find_project(pwd: &Path, file: &str) -> CargoResult<Path> {
-    find_project_manifest(pwd, file)
-        .map(|mut p| {
-            // remove the file, leaving just the directory
-            p.pop();
-            p
-        })
+    find_project_manifest(pwd, file).map(|mut p| {
+        // remove the file, leaving just the directory
+        p.pop();
+        p
+    })
 }
 
 /// Iteratively search for `file` in `pwd` and its parents, returning
@@ -32,16 +31,15 @@ pub fn find_project_manifest(pwd: &Path, file: &str) -> CargoResult<Path> {
 }
 
 /// Find the root Cargo.toml
-pub fn find_root_manifest_for_cwd(manifest_path: Option<String>) -> CliResult<Path> {
-    manifest_path.map(|path| Ok(Path::new(path))).unwrap_or_else(|| os::getcwd()
-        .map_err(|_| CliError::new("Couldn't determine the current working directory", 103))
-        .and_then(|cwd| find_project_manifest(&cwd, "Cargo.toml")
-            .map_err(|_| CliError::new("Could not find Cargo.toml in this \
-                    directory or any parent directory", 102))
-        )
-    )
-        .and_then(|path| os::make_absolute(&path).map_err(|_|
-            CliError::new("Could not determine the absolute path of the manifest", 104)))
+pub fn find_root_manifest_for_cwd(manifest_path: Option<String>)
+                                  -> CargoResult<Path> {
+    let cwd = try!(env::current_dir().chain_error(|| {
+        human("Couldn't determine the current working directory")
+    }));
+    match manifest_path {
+        Some(path) => Ok(cwd.join(path)),
+        None => find_project_manifest(&cwd, "Cargo.toml"),
+    }
 }
 
 /// Return the path to the `file` in `pwd`, if it exists.
index 20525c4dbe1eba20fbdb6680873d529f525a7502..3284681c2b620abf09e4666af6204a325ad33861 100644 (file)
@@ -1,12 +1,15 @@
-use std::{old_io,os};
+use std::env;
 use std::old_io::fs;
-use std::path::BytesContainer;
+use std::old_io;
+use std::old_path::BytesContainer;
+use std::os;
 
 use util::{human, CargoResult};
 
 pub fn realpath(original: &Path) -> old_io::IoResult<Path> {
     const MAX_LINKS_FOLLOWED: usize = 256;
-    let original = try!(os::make_absolute(original));
+    let cwd = try!(env::current_dir());
+    let original = cwd.join(original);
 
     // Right now lstat on windows doesn't work quite well
     if cfg!(windows) {
@@ -41,6 +44,7 @@ pub fn realpath(original: &Path) -> old_io::IoResult<Path> {
     return Ok(result);
 }
 
+#[allow(deprecated)] // need an OsStr-based Command first
 pub fn join_paths<T: BytesContainer>(paths: &[T], env: &str)
                                      -> CargoResult<Vec<u8>> {
     os::join_paths(paths).map_err(|e| {
index 28de7dfff3bb71a31ef93c6b7b95d0f98ef1d39e..a29b3b9025fd8500e8cdf9357379c70f11644b04 100644 (file)
@@ -1,9 +1,9 @@
 use std::collections::HashMap;
+use std::env;
 use std::ffi::CString;
 use std::fmt::{self, Formatter};
 use std::old_io::process::{Command, ProcessOutput, InheritFd};
-use std::os;
-use std::path::BytesContainer;
+use std::old_path::BytesContainer;
 
 use util::{CargoResult, ProcessError, process_error};
 
@@ -126,7 +126,7 @@ pub fn process<T: BytesContainer>(cmd: T) -> CargoResult<ProcessBuilder> {
     Ok(ProcessBuilder {
         program: CString::from_slice(cmd.container_as_bytes()),
         args: Vec::new(),
-        cwd: try!(os::getcwd()),
+        cwd: try!(env::current_dir()),
         env: HashMap::new(),
     })
 }
index c5aa87ed4e437c10ea8df6fd612eeed272f9bb1d..e17df6d22166ba59d381641e81e4405aab55e504 100644 (file)
@@ -1,6 +1,6 @@
-use std::os;
-use std::mem;
+use std::env;
 use std::fmt;
+use std::mem;
 use time;
 use std::iter::repeat;
 use std::cell::RefCell;
@@ -14,7 +14,7 @@ pub struct Profiler {
     desc: String,
 }
 
-fn enabled() -> bool { os::getenv("CARGO_PROFILE").is_some() }
+fn enabled() -> bool { env::var("CARGO_PROFILE").is_some() }
 
 pub fn start<T: fmt::Display>(desc: T) -> Profiler {
     if !enabled() { return Profiler { desc: String::new() } }
index d86b75bb8ba96354e09049a46a6f6e7d0a61de94..cab0a356abdf4f70e2ca486fce926f2f78a61de5 100644 (file)
@@ -2,7 +2,6 @@ use std::collections::HashMap;
 
 use std::fmt;
 use std::old_io::fs::{self, PathExtensions};
-use std::os;
 use std::slice;
 use std::str;
 use std::default::Default;
@@ -95,7 +94,7 @@ pub fn to_manifest(contents: &[u8],
                    config: &Config)
                    -> CargoResult<(Manifest, Vec<Path>)> {
     let manifest = layout.root.join("Cargo.toml");
-    let manifest = match manifest.path_relative_from(&try!(os::getcwd())) {
+    let manifest = match manifest.path_relative_from(config.cwd()) {
         Some(path) => path,
         None => manifest,
     };
index 54b77685e14cefa7159cb8efb4d62fa16ff60fa5..0d845a26a7e861627b87717183d5b9811d879fad 100644 (file)
@@ -1 +1 @@
-2015-02-03
+2015-02-05
index 4fe302caf248c0eb246532c6bf71cefd290a9683..83be2957b78e00cc1bb453d363970020e0b57fbe 100644 (file)
@@ -1,10 +1,10 @@
 use std::error::Error;
+use std::env;
 use std::fmt;
 use std::old_io::fs::{self, PathExtensions};
 use std::old_io::process::{ProcessOutput};
 use std::old_io;
-use std::os;
-use std::path::{Path, BytesContainer};
+use std::old_path::{Path, BytesContainer};
 use std::str::{self, Str};
 
 use url::Url;
@@ -102,16 +102,17 @@ impl ProjectBuilder {
     pub fn url(&self) -> Url { path2url(self.root()) }
 
     pub fn bin(&self, b: &str) -> Path {
-        self.build_dir().join(format!("{}{}", b, os::consts::EXE_SUFFIX))
+        self.build_dir().join(format!("{}{}", b, env::consts::EXE_SUFFIX))
     }
 
     pub fn release_bin(&self, b: &str) -> Path {
-        self.build_dir().join("release").join(format!("{}{}", b, os::consts::EXE_SUFFIX))
+        self.build_dir().join("release").join(format!("{}{}", b,
+                                                      env::consts::EXE_SUFFIX))
     }
 
     pub fn target_bin(&self, target: &str, b: &str) -> Path {
         self.build_dir().join(target).join(format!("{}{}", b,
-                                                   os::consts::EXE_SUFFIX))
+                                                   env::consts::EXE_SUFFIX))
     }
 
     pub fn build_dir(&self) -> Path {
@@ -226,8 +227,8 @@ impl<T, E: fmt::Display> ErrMsg<T> for Result<T, E> {
 
 // Path to cargo executables
 pub fn cargo_dir() -> Path {
-    os::getenv("CARGO_BIN_PATH").map(Path::new)
-        .or_else(|| os::self_exe_path())
+    env::var_string("CARGO_BIN_PATH").map(Path::new).ok()
+        .or_else(|| env::current_exe().ok().map(|s| s.dir_path()))
         .unwrap_or_else(|| {
             panic!("CARGO_BIN_PATH wasn't set. Cannot continue running test")
         })
index cbecafcf66fd14d87503ee9f815f5b22786bca22..1a2d637649758d9747f6389b3c70f57265460aea 100644 (file)
@@ -1,7 +1,8 @@
 use std::old_io::IoResult;
+use std::env;
 use std::old_io::fs::{self, PathExtensions};
 use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
-use std::{old_io, os};
+use std::old_io;
 
 use cargo::util::realpath;
 
@@ -10,7 +11,8 @@ static NEXT_ID: AtomicUsize = ATOMIC_USIZE_INIT;
 thread_local!(static TASK_ID: usize = NEXT_ID.fetch_add(1, Ordering::SeqCst));
 
 pub fn root() -> Path {
-    let path = os::self_exe_path().unwrap()
+    let path = env::current_exe().unwrap()
+                  .dir_path()
                   .join(CARGO_INTEGRATION_TEST_DIR)
                   .join(TASK_ID.with(|my_id| format!("test-{}", my_id)));
     realpath(&path).unwrap()
index 2eda962b470fa0a5706bfc2caefe4d83dfb25c16..b4b1abd14984fb3505a4569f85aaa22ce7582302 100644 (file)
@@ -1,7 +1,8 @@
+use std::env;
+use std::ffi::OsString;
 use std::old_io::fs;
-use std::old_io;
 use std::old_io::{USER_RWX, File};
-use std::os;
+use std::old_io;
 use std::str;
 use cargo::util::process;
 
@@ -15,7 +16,7 @@ fn setup() {
 /// Add an empty file with executable flags (and platform-dependent suffix).
 /// TODO: move this to `ProjectBuilder` if other cases using this emerge.
 fn fake_executable(proj: ProjectBuilder, dir: &Path, name: &str) -> ProjectBuilder {
-    let path = proj.root().join(dir).join(format!("{}{}", name, os::consts::EXE_SUFFIX));
+    let path = proj.root().join(dir).join(format!("{}{}", name, env::consts::EXE_SUFFIX));
     mkdir_recursive(&Path::new(path.dirname())).unwrap();
     fs::File::create(&path).unwrap();
     let old_io::FileStat{perm, ..} = fs::stat(&path).unwrap();
@@ -24,9 +25,9 @@ fn fake_executable(proj: ProjectBuilder, dir: &Path, name: &str) -> ProjectBuild
 }
 
 fn path() -> Vec<Path> {
-    let path = os::getenv_as_bytes("PATH").unwrap_or(Vec::new());
-    os::split_paths(path)
+    env::split_paths(&env::var("PATH").unwrap_or(OsString::new())).collect()
 }
+
 test!(list_commands_looks_at_path {
     let proj = project("list-non-overlapping");
     let proj = fake_executable(proj, &Path::new("path-test"), "cargo-1");
@@ -37,8 +38,9 @@ test!(list_commands_looks_at_path {
 
     let mut path = path();
     path.push(proj.root().join("path-test"));
-    let path = os::join_paths(path.as_slice()).unwrap();
-    let output = pr.arg("-v").arg("--list").env("PATH", Some(path.as_slice()));
+    let path = env::join_paths(path.iter()).unwrap();
+    let output = pr.arg("-v").arg("--list")
+                   .env("PATH", Some(path.to_str().unwrap()));
     let output = output.exec_with_output().unwrap();
     let output = str::from_utf8(output.output.as_slice()).unwrap();
     assert!(output.contains("\n    1\n"), "missing 1: {}", output);
index 9d472b7f7440a31bfa3029d8f60bed456a6f51a2..7237a71d3bea6a20bff094493905a1627b0c311d 100644 (file)
@@ -1,4 +1,4 @@
-use std::path;
+use std::old_path;
 use std::str;
 
 use support::{project, execs, basic_bin_manifest, basic_lib_manifest};
@@ -186,7 +186,7 @@ thread '<main>' panicked at 'assertion failed: \
     `(left == right) && (right == left)` (left: \
     `\"hello\"`, right: `\"nope\"`)', src{sep}foo.rs:14
 
-", sep = path::SEP))
+", sep = old_path::SEP))
               .with_status(101));
 });
 
@@ -865,5 +865,5 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
                        running = RUNNING,
                        dir = p.root().display(),
                        url = p.url(),
-                       sep = path::SEP).as_slice()));
+                       sep = old_path::SEP).as_slice()));
 });
index 6b6064a3a4d2b1b01de2bffa6c248f8ed381545c..ee0842b33d8dba7c9a2d16a618d705d58f9ef2be 100644 (file)
@@ -1,4 +1,4 @@
-use std::path;
+use std::old_path;
 use support::{basic_bin_manifest, execs, project, ProjectBuilder};
 use support::{COMPILING, RUNNING};
 use hamcrest::{assert_that};
@@ -17,7 +17,7 @@ fn verbose_output_for_lib(p: &ProjectBuilder) -> String {
         -L dependency={dir}{sep}target \
         -L dependency={dir}{sep}target{sep}deps`
 ",
-            running = RUNNING, compiling = COMPILING, sep = path::SEP,
+            running = RUNNING, compiling = COMPILING, sep = old_path::SEP,
             dir = p.root().display(), url = p.url(),
             name = "foo", version = "0.0.1")
 }
index 886c7dfc16f702699a47d789f2c0beca1bdd8efe..6fd759f69af52d90f726ffa4900d7f66c94fc95b 100644 (file)
@@ -1,6 +1,6 @@
 use std::old_io::{self, fs, TempDir, File};
-use std::os;
-use std::path;
+use std::env;
+use std::old_path;
 
 use support::{project, execs, main_file, basic_bin_manifest};
 use support::{COMPILING, RUNNING, cargo_dir, ProjectBuilder};
@@ -119,10 +119,10 @@ test!(cargo_compile_without_manifest {
     let p = ProjectBuilder::new("foo", tmpdir.path().clone());
 
     assert_that(p.cargo_process("build"),
-        execs()
-        .with_status(102)
-        .with_stderr("Could not find Cargo.toml in this directory or any \
-                      parent directory\n"));
+                execs().with_status(101)
+                       .with_stderr("\
+Could not find `Cargo.toml` in `[..]` or any parent directory
+"));
 });
 
 test!(cargo_compile_with_invalid_code {
@@ -140,7 +140,7 @@ test!(cargo_compile_with_invalid_code {
 Could not compile `foo`.
 
 To learn more, run the command again with --verbose.\n",
-            filename = format!("src{}foo.rs", path::SEP)).as_slice()));
+            filename = format!("src{}foo.rs", old_path::SEP)).as_slice()));
     assert_that(&p.root().join("Cargo.lock"), existing_file());
 });
 
@@ -181,7 +181,7 @@ test!(cargo_compile_with_warnings_in_the_root_package {
 on by default
 {filename}:1 fn main() {{}} fn dead() {{}}
                           ^~~~~~~~~~~~
-", filename = format!("src{}foo.rs", path::SEP).as_slice())));
+", filename = format!("src{}foo.rs", old_path::SEP).as_slice())));
 });
 
 test!(cargo_compile_with_warnings_in_a_dep_package {
@@ -648,8 +648,8 @@ test!(many_crate_types_old_style_lib_location {
     let file1 = files[1].as_slice();
     println!("{} {}", file0, file1);
     assert!(file0.ends_with(".rlib") || file1.ends_with(".rlib"));
-    assert!(file0.ends_with(os::consts::DLL_SUFFIX) ||
-            file1.ends_with(os::consts::DLL_SUFFIX));
+    assert!(file0.ends_with(env::consts::DLL_SUFFIX) ||
+            file1.ends_with(env::consts::DLL_SUFFIX));
 });
 
 test!(many_crate_types_correct {
@@ -686,8 +686,8 @@ test!(many_crate_types_correct {
     let file1 = files[1].as_slice();
     println!("{} {}", file0, file1);
     assert!(file0.ends_with(".rlib") || file1.ends_with(".rlib"));
-    assert!(file0.ends_with(os::consts::DLL_SUFFIX) ||
-            file1.ends_with(os::consts::DLL_SUFFIX));
+    assert!(file0.ends_with(env::consts::DLL_SUFFIX) ||
+            file1.ends_with(env::consts::DLL_SUFFIX));
 });
 
 test!(unused_keys {
@@ -822,7 +822,7 @@ test!(lto_build {
         -L dependency={dir}{sep}target{sep}release \
         -L dependency={dir}{sep}target{sep}release{sep}deps`
 ",
-running = RUNNING, compiling = COMPILING, sep = path::SEP,
+running = RUNNING, compiling = COMPILING, sep = old_path::SEP,
 dir = p.root().display(),
 url = p.url(),
 )));
@@ -850,7 +850,7 @@ test!(verbose_build {
         -L dependency={dir}{sep}target \
         -L dependency={dir}{sep}target{sep}deps`
 ",
-running = RUNNING, compiling = COMPILING, sep = path::SEP,
+running = RUNNING, compiling = COMPILING, sep = old_path::SEP,
 dir = p.root().display(),
 url = p.url(),
 )));
@@ -880,7 +880,7 @@ test!(verbose_release_build {
         -L dependency={dir}{sep}target{sep}release \
         -L dependency={dir}{sep}target{sep}release{sep}deps`
 ",
-running = RUNNING, compiling = COMPILING, sep = path::SEP,
+running = RUNNING, compiling = COMPILING, sep = old_path::SEP,
 dir = p.root().display(),
 url = p.url(),
 )));
@@ -943,9 +943,9 @@ test!(verbose_release_build_deps {
                     compiling = COMPILING,
                     dir = p.root().display(),
                     url = p.url(),
-                    sep = path::SEP,
-                    prefix = os::consts::DLL_PREFIX,
-                    suffix = os::consts::DLL_SUFFIX).as_slice()));
+                    sep = old_path::SEP,
+                    prefix = env::consts::DLL_PREFIX,
+                    suffix = env::consts::DLL_SUFFIX).as_slice()));
 });
 
 test!(explicit_examples {
@@ -1293,12 +1293,12 @@ test!(rebuild_preserves_out_dir {
             build = 'build.rs'
         "#)
         .file("build.rs", r#"
-            use std::os;
+            use std::env;
             use std::old_io::File;
 
             fn main() {
-                let path = Path::new(os::getenv("OUT_DIR").unwrap()).join("foo");
-                if os::getenv("FIRST").is_some() {
+                let path = Path::new(env::var_string("OUT_DIR").unwrap()).join("foo");
+                if env::var("FIRST").is_some() {
                     File::create(&path).unwrap();
                 } else {
                     File::create(&path).unwrap();
index bf80eebaf5abba4f591f7642cf506159c1cb00db..038ec33f5a68e21553fe045bbb30a213863e4e7c 100644 (file)
@@ -1,5 +1,5 @@
+use std::env;
 use std::old_io::{File, fs};
-use std::os;
 
 use support::{project, execs, cargo_dir};
 use support::{COMPILING, RUNNING, DOCTEST};
@@ -23,9 +23,9 @@ test!(custom_build_script_failed {
             fn main() {}
         "#)
         .file("build.rs", r#"
-            #![feature(os)]
+            #![feature(env)]
             fn main() {
-                std::os::set_exit_status(101);
+                std::env::set_exit_status(101);
             }
         "#);
     assert_that(p.cargo_process("build").arg("-v"),
@@ -76,34 +76,35 @@ test!(custom_build_env_vars {
         "#);
 
     let file_content = format!(r#"
-            use std::os;
+            use std::env;
             use std::old_io::fs::PathExtensions;
             fn main() {{
-                let _target = os::getenv("TARGET").unwrap();
+                let _target = env::var_string("TARGET").unwrap();
 
-                let _ncpus = os::getenv("NUM_JOBS").unwrap();
+                let _ncpus = env::var_string("NUM_JOBS").unwrap();
 
-                let out = os::getenv("CARGO_MANIFEST_DIR").unwrap();
+                let out = env::var_string("CARGO_MANIFEST_DIR").unwrap();
                 let p1 = Path::new(out);
-                let p2 = os::make_absolute(&Path::new(file!()).dir_path().dir_path()).unwrap();
+                let cwd = env::current_dir().unwrap();
+                let p2 = cwd.join(Path::new(file!()).dir_path().dir_path());
                 assert!(p1 == p2, "{{}} != {{}}", p1.display(), p2.display());
 
-                let opt = os::getenv("OPT_LEVEL").unwrap();
+                let opt = env::var_string("OPT_LEVEL").unwrap();
                 assert_eq!(opt.as_slice(), "0");
 
-                let opt = os::getenv("PROFILE").unwrap();
+                let opt = env::var_string("PROFILE").unwrap();
                 assert_eq!(opt.as_slice(), "compile");
 
-                let debug = os::getenv("DEBUG").unwrap();
+                let debug = env::var_string("DEBUG").unwrap();
                 assert_eq!(debug.as_slice(), "true");
 
-                let out = os::getenv("OUT_DIR").unwrap();
+                let out = env::var_string("OUT_DIR").unwrap();
                 assert!(out.as_slice().starts_with(r"{0}"));
                 assert!(Path::new(out).is_dir());
 
-                let _host = os::getenv("HOST").unwrap();
+                let _host = env::var_string("HOST").unwrap();
 
-                let _feat = os::getenv("CARGO_FEATURE_FOO").unwrap();
+                let _feat = env::var_string("CARGO_FEATURE_FOO").unwrap();
             }}
         "#,
         p.root().join("target").join("build").display());
@@ -266,10 +267,10 @@ test!(overrides_and_links {
         "#)
         .file("src/lib.rs", "")
         .file("build.rs", r#"
-            use std::os;
+            use std::env;
             fn main() {
-                assert_eq!(os::getenv("DEP_FOO_FOO").unwrap().as_slice(), "bar");
-                assert_eq!(os::getenv("DEP_FOO_BAR").unwrap().as_slice(), "baz");
+                assert_eq!(env::var_string("DEP_FOO_FOO").unwrap().as_slice(), "bar");
+                assert_eq!(env::var_string("DEP_FOO_BAR").unwrap().as_slice(), "baz");
             }
         "#)
         .file(".cargo/config", format!(r#"
@@ -339,10 +340,10 @@ test!(links_passes_env_vars {
         "#)
         .file("src/lib.rs", "")
         .file("build.rs", r#"
-            use std::os;
+            use std::env;
             fn main() {
-                assert_eq!(os::getenv("DEP_FOO_FOO").unwrap().as_slice(), "bar");
-                assert_eq!(os::getenv("DEP_FOO_BAR").unwrap().as_slice(), "baz");
+                assert_eq!(env::var_string("DEP_FOO_FOO").unwrap().as_slice(), "bar");
+                assert_eq!(env::var_string("DEP_FOO_BAR").unwrap().as_slice(), "baz");
             }
         "#)
         .file("a/Cargo.toml", r#"
@@ -438,10 +439,10 @@ test!(rebuild_continues_to_pass_env_vars {
         "#, a.root().display()))
         .file("src/lib.rs", "")
         .file("build.rs", r#"
-            use std::os;
+            use std::env;
             fn main() {
-                assert_eq!(os::getenv("DEP_FOO_FOO").unwrap().as_slice(), "bar");
-                assert_eq!(os::getenv("DEP_FOO_BAR").unwrap().as_slice(), "baz");
+                assert_eq!(env::var_string("DEP_FOO_FOO").unwrap().as_slice(), "bar");
+                assert_eq!(env::var_string("DEP_FOO_BAR").unwrap().as_slice(), "baz");
             }
         "#);
 
@@ -723,10 +724,10 @@ test!(out_dir_is_preserved {
         "#)
         .file("src/lib.rs", "")
         .file("build.rs", r#"
-            use std::os;
+            use std::env;
             use std::old_io::File;
             fn main() {
-                let out = os::getenv("OUT_DIR").unwrap();
+                let out = env::var_string("OUT_DIR").unwrap();
                 File::create(&Path::new(out).join("foo")).unwrap();
             }
         "#);
@@ -738,10 +739,10 @@ test!(out_dir_is_preserved {
 
     // Change to asserting that it's there
     File::create(&p.root().join("build.rs")).write_str(r#"
-        use std::os;
+        use std::env;
         use std::old_io::File;
         fn main() {
-            let out = os::getenv("OUT_DIR").unwrap();
+            let out = env::var_string("OUT_DIR").unwrap();
             File::open(&Path::new(out).join("foo")).unwrap();
         }
     "#).unwrap();
@@ -803,11 +804,11 @@ test!(code_generation {
             }
         "#)
         .file("build.rs", r#"
-            use std::os;
+            use std::env;
             use std::old_io::File;
 
             fn main() {
-                let dst = Path::new(os::getenv("OUT_DIR").unwrap());
+                let dst = Path::new(env::var_string("OUT_DIR").unwrap());
                 let mut f = File::create(&dst.join("hello.rs")).unwrap();
                 f.write_str("
                     pub fn message() -> &'static str {
@@ -967,11 +968,11 @@ test!(test_a_lib_with_a_build_command {
             }
         "#)
         .file("build.rs", r#"
-            use std::os;
+            use std::env;
             use std::old_io::File;
 
             fn main() {
-                let out = Path::new(os::getenv("OUT_DIR").unwrap());
+                let out = Path::new(env::var_string("OUT_DIR").unwrap());
                 File::create(&out.join("foo.rs")).write_str("
                     fn foo() -> int { 1 }
                 ").unwrap();
@@ -1027,12 +1028,12 @@ test!(build_script_with_dynamic_native_dependency {
     let src = build.root().join("target");
     let lib = fs::readdir(&src).unwrap().into_iter().find(|lib| {
         let lib = lib.filename_str().unwrap();
-        lib.starts_with(os::consts::DLL_PREFIX) &&
-            lib.ends_with(os::consts::DLL_SUFFIX)
+        lib.starts_with(env::consts::DLL_PREFIX) &&
+            lib.ends_with(env::consts::DLL_SUFFIX)
     }).unwrap();
     let libname = lib.filename_str().unwrap();
-    let libname = &libname[os::consts::DLL_PREFIX.len()..
-                           libname.len() - os::consts::DLL_SUFFIX.len()];
+    let libname = &libname[env::consts::DLL_PREFIX.len()..
+                           libname.len() - env::consts::DLL_SUFFIX.len()];
 
     let foo = project("foo")
         .file("Cargo.toml", r#"
@@ -1058,10 +1059,10 @@ test!(build_script_with_dynamic_native_dependency {
             build = "build.rs"
         "#)
         .file("bar/build.rs", r#"
-            use std::os;
+            use std::env;
 
             fn main() {
-                let src = Path::new(os::getenv("SRC").unwrap());
+                let src = Path::new(env::var_string("SRC").unwrap());
                 println!("cargo:rustc-flags=-L {}", src.dir_path().display());
             }
         "#)
index e375e372747c4e8d08556aaf06d9f87ad63d2277..853038ff3536afa9a9dfb6a0c26b249994735797 100644 (file)
@@ -1,5 +1,5 @@
 use std::old_io::fs;
-use std::os;
+use std::env;
 
 use support::{project, execs, cargo_dir};
 use hamcrest::assert_that;
@@ -103,12 +103,12 @@ test!(plugin_with_dynamic_native_dependency {
     let src = build.root().join("target");
     let lib = fs::readdir(&src).unwrap().into_iter().find(|lib| {
         let lib = lib.filename_str().unwrap();
-        lib.starts_with(os::consts::DLL_PREFIX) &&
-            lib.ends_with(os::consts::DLL_SUFFIX)
+        lib.starts_with(env::consts::DLL_PREFIX) &&
+            lib.ends_with(env::consts::DLL_SUFFIX)
     }).unwrap();
     let libname = lib.filename_str().unwrap();
-    let libname = &libname[os::consts::DLL_PREFIX.len()..
-                           libname.len() - os::consts::DLL_SUFFIX.len()];
+    let libname = &libname[env::consts::DLL_PREFIX.len()..
+                           libname.len() - env::consts::DLL_SUFFIX.len()];
 
     let foo = project("foo")
         .file("Cargo.toml", r#"
index ccd79bc5349131b8e4f3ef108b02b47e1d5d8c8e..a2d53e0bbf79d7f32acde6a6f0505dafde6cdb3c 100644 (file)
@@ -1,5 +1,5 @@
-use std::os;
-use std::path;
+use std::env;
+use std::old_path;
 
 use support::{project, execs, basic_bin_manifest};
 use support::{RUNNING, COMPILING, DOCTEST, cargo_dir};
@@ -12,8 +12,8 @@ fn setup() {
 
 fn disabled() -> bool {
     // First, disable if ./configure requested so
-    match os::getenv("CFG_DISABLE_CROSS_TESTS") {
-        Some(ref s) if s.as_slice() == "1" => return true,
+    match env::var_string("CFG_DISABLE_CROSS_TESTS") {
+        Ok(ref s) if s.as_slice() == "1" => return true,
         _ => {}
     }
 
@@ -24,7 +24,7 @@ fn disabled() -> bool {
 }
 
 fn alternate() -> &'static str {
-    match os::consts::SYSNAME {
+    match env::consts::OS {
         "linux" => "i686-unknown-linux-gnu",
         "macos" => "i686-apple-darwin",
         _ => unreachable!(),
@@ -44,13 +44,13 @@ test!(simple_cross {
         "#)
         .file("build.rs", format!(r#"
             fn main() {{
-                assert_eq!(std::os::getenv("TARGET").unwrap().as_slice(), "{}");
+                assert_eq!(std::env::var_string("TARGET").unwrap().as_slice(), "{}");
             }}
         "#, alternate()).as_slice())
         .file("src/main.rs", r#"
-            use std::os;
+            use std::env;
             fn main() {
-                assert_eq!(os::consts::ARCH, "x86");
+                assert_eq!(env::consts::ARCH, "x86");
             }
         "#);
 
@@ -277,9 +277,9 @@ test!(linker_and_ar {
         "#, target).as_slice())
         .file("Cargo.toml", basic_bin_manifest("foo").as_slice())
         .file("src/foo.rs", r#"
-            use std::os;
+            use std::env;
             fn main() {
-                assert_eq!(os::consts::ARCH, "x86");
+                assert_eq!(env::consts::ARCH, "x86");
             }
         "#);
 
@@ -301,7 +301,7 @@ test!(linker_and_ar {
                             dir = p.root().display(),
                             url = p.url(),
                             target = target,
-                            sep = path::SEP,
+                            sep = old_path::SEP,
                             ).as_slice()));
 });
 
@@ -386,15 +386,15 @@ test!(cross_tests {
         "#)
         .file("src/main.rs", r#"
             extern crate foo;
-            use std::os;
+            use std::env;
             fn main() {
-                assert_eq!(os::consts::ARCH, "x86");
+                assert_eq!(env::consts::ARCH, "x86");
             }
             #[test] fn test() { main() }
         "#)
         .file("src/lib.rs", r#"
-            use std::os;
-            pub fn foo() { assert_eq!(os::consts::ARCH, "x86"); }
+            use std::env;
+            pub fn foo() { assert_eq!(env::consts::ARCH, "x86"); }
             #[test] fn test_foo() { foo() }
         "#);
 
@@ -438,9 +438,9 @@ test!(simple_cargo_run {
             authors = []
         "#)
         .file("src/main.rs", r#"
-            use std::os;
+            use std::env;
             fn main() {
-                assert_eq!(os::consts::ARCH, "x86");
+                assert_eq!(env::consts::ARCH, "x86");
             }
         "#);
 
@@ -462,10 +462,10 @@ test!(cross_with_a_build_script {
             build = 'build.rs'
         "#)
         .file("build.rs", format!(r#"
-            use std::os;
+            use std::env;
             fn main() {{
-                assert_eq!(os::getenv("TARGET").unwrap().as_slice(), "{0}");
-                let mut path = Path::new(os::getenv("OUT_DIR").unwrap());
+                assert_eq!(env::var_string("TARGET").unwrap().as_slice(), "{0}");
+                let mut path = Path::new(env::var_string("OUT_DIR").unwrap());
                 assert_eq!(path.filename().unwrap(), b"out");
                 path.pop();
                 assert!(path.filename().unwrap().starts_with(b"foo-"));
@@ -487,7 +487,7 @@ test!(cross_with_a_build_script {
 {running} `{dir}{sep}target{sep}build{sep}foo-[..]build-script-build`
 {running} `rustc src{sep}main.rs [..] --target {target} [..]`
 ", compiling = COMPILING, running = RUNNING, target = target,
-   dir = p.root().display(), sep = path::SEP).as_slice()));
+   dir = p.root().display(), sep = old_path::SEP).as_slice()));
 });
 
 test!(build_script_needed_for_host_and_target {
@@ -528,9 +528,9 @@ test!(build_script_needed_for_host_and_target {
             pub fn d1() {}
         ")
         .file("d1/build.rs", r#"
-            use std::os;
+            use std::env;
             fn main() {
-                let target = os::getenv("TARGET").unwrap();
+                let target = env::var_string("TARGET").unwrap();
                 println!("cargo:rustc-flags=-L /path/to/{}", target);
             }
         "#)
@@ -569,7 +569,7 @@ test!(build_script_needed_for_host_and_target {
 {running} `rustc src{sep}main.rs [..] --target {target} [..] \
            -L /path/to/{target}`
 ", compiling = COMPILING, running = RUNNING, target = target, host = host,
-   dir = p.root().display(), sep = path::SEP).as_slice()));
+   dir = p.root().display(), sep = old_path::SEP).as_slice()));
 });
 
 test!(build_deps_for_the_right_arch {
@@ -640,12 +640,12 @@ test!(build_script_only_host {
             pub fn d1() {}
         ")
         .file("d1/build.rs", r#"
-            use std::os;
+            use std::env;
 
             fn main() {
-                assert!(os::getenv("OUT_DIR").unwrap()
+                assert!(env::var_string("OUT_DIR").unwrap()
                                              .contains("target/build/d1-"),
-                        "bad: {:?}", os::getenv("OUT_DIR"));
+                        "bad: {:?}", env::var_string("OUT_DIR"));
             }
         "#);
 
index b78d42c8c5469996eea73337bc472f8c28096608..3dfdfea55d5aaead66d68bc7252603567e88f4b2 100644 (file)
@@ -1,6 +1,6 @@
 use std::old_io::{fs, USER_RWX, File, TempDir};
 use std::old_io::fs::PathExtensions;
-use std::os;
+use std::env;
 
 use support::{execs, paths, cargo_dir};
 use hamcrest::{assert_that, existing_file, existing_dir, is_not};
@@ -23,8 +23,8 @@ fn cargo_process(s: &str) -> ProcessBuilder {
 }
 
 test!(simple_lib {
-    os::setenv("USER", "foo");
-    assert_that(cargo_process("new").arg("foo").arg("--vcs").arg("none"),
+    assert_that(cargo_process("new").arg("foo").arg("--vcs").arg("none")
+                                    .env("USER", Some("foo")),
                 execs().with_status(0));
 
     assert_that(&paths::root().join("foo"), existing_dir());
@@ -37,8 +37,8 @@ test!(simple_lib {
 });
 
 test!(simple_bin {
-    os::setenv("USER", "foo");
-    assert_that(cargo_process("new").arg("foo").arg("--bin"),
+    assert_that(cargo_process("new").arg("foo").arg("--bin")
+                                    .env("USER", Some("foo")),
                 execs().with_status(0));
 
     assert_that(&paths::root().join("foo"), existing_dir());
@@ -48,14 +48,14 @@ test!(simple_bin {
     assert_that(cargo_process("build").cwd(paths::root().join("foo")),
                 execs().with_status(0));
     assert_that(&paths::root().join(format!("foo/target/foo{}",
-                                            os::consts::EXE_SUFFIX)),
+                                            env::consts::EXE_SUFFIX)),
                 existing_file());
 });
 
 test!(simple_git {
     let td = TempDir::new("cargo").unwrap();
-    os::setenv("USER", "foo");
-    assert_that(cargo_process("new").arg("foo").cwd(td.path().clone()),
+    assert_that(cargo_process("new").arg("foo").cwd(td.path().clone())
+                                    .env("USER", Some("foo")),
                 execs().with_status(0));
 
     assert_that(td.path(), existing_dir());
@@ -175,8 +175,8 @@ test!(git_prefers_command_line {
 });
 
 test!(subpackage_no_git {
-    os::setenv("USER", "foo");
-    assert_that(cargo_process("new").arg("foo"), execs().with_status(0));
+    assert_that(cargo_process("new").arg("foo").env("USER", Some("foo")),
+                execs().with_status(0));
 
     let subpackage = paths::root().join("foo").join("components");
     fs::mkdir(&subpackage, USER_RWX).unwrap();
index e4f0cd67c2909f5431a4520b439529d9bbd3d0fe..b71eadb344942e9772389406c1fdaf205182f17f 100644 (file)
@@ -1,5 +1,5 @@
 use std::os;
-use std::path;
+use std::old_path;
 
 use support::{project, execs};
 use support::{COMPILING, RUNNING};
@@ -38,7 +38,7 @@ test!(profile_overrides {
         -L dependency={dir}{sep}target \
         -L dependency={dir}{sep}target{sep}deps`
 ",
-running = RUNNING, compiling = COMPILING, sep = path::SEP,
+running = RUNNING, compiling = COMPILING, sep = old_path::SEP,
 dir = p.root().display(),
 url = p.url(),
 )));
@@ -109,7 +109,7 @@ test!(top_level_overrides_deps {
                     compiling = COMPILING,
                     dir = p.root().display(),
                     url = p.url(),
-                    sep = path::SEP,
+                    sep = old_path::SEP,
                     prefix = os::consts::DLL_PREFIX,
                     suffix = os::consts::DLL_SUFFIX).as_slice()));
 });
index f8077f395644d11d37660716e41c610ae6fe4449..1abd19dc1fa42a013b00b9ca71b3d6ae74d07f0d 100644 (file)
@@ -1,4 +1,4 @@
-use std::path;
+use std::old_path;
 
 use support::{project, cargo_dir, execs, path2url};
 use support::{COMPILING, RUNNING};
@@ -28,7 +28,7 @@ hello
         compiling = COMPILING,
         running = RUNNING,
         dir = path2url(p.root()),
-        sep = path::SEP).as_slice()));
+        sep = old_path::SEP).as_slice()));
     assert_that(&p.bin("foo"), existing_file());
 });
 
@@ -129,7 +129,7 @@ hello a.rs
         compiling = COMPILING,
         running = RUNNING,
         dir = path2url(p.root()),
-        sep = path::SEP).as_slice()));
+        sep = old_path::SEP).as_slice()));
 
     assert_that(p.process(cargo_dir().join("cargo")).arg("run").arg("--bin").arg("b"),
                 execs().with_status(0).with_stdout(format!("\
@@ -137,7 +137,7 @@ hello a.rs
 hello b.rs
 ",
         running = RUNNING,
-        sep = path::SEP).as_slice()));
+        sep = old_path::SEP).as_slice()));
 });
 
 test!(run_example {
@@ -165,7 +165,7 @@ example
         compiling = COMPILING,
         running = RUNNING,
         dir = path2url(p.root()),
-        sep = path::SEP).as_slice()));
+        sep = old_path::SEP).as_slice()));
 });
 
 test!(either_name_or_example {
@@ -217,7 +217,7 @@ hello main.rs
         compiling = COMPILING,
         running = RUNNING,
         dir = path2url(p.root()),
-        sep = path::SEP).as_slice()));
+        sep = old_path::SEP).as_slice()));
 });
 
 test!(example_with_release_flag {
@@ -292,7 +292,7 @@ fast2
         running = RUNNING,
         dir = p.root().display(),
         url = path2url(p.root()),
-        sep = path::SEP).as_slice()));
+        sep = old_path::SEP).as_slice()));
 
     assert_that(p.process(cargo_dir().join("cargo")).arg("run").arg("-v").arg("--example").arg("a"),
                 execs().with_status(0).with_stdout(format!("\
@@ -321,7 +321,7 @@ slow2
         running = RUNNING,
         dir = p.root().display(),
         url = path2url(p.root()),
-        sep = path::SEP).as_slice()));
+        sep = old_path::SEP).as_slice()));
 });
 
 test!(run_dylib_dep {
@@ -375,7 +375,7 @@ test!(release_works {
         compiling = COMPILING,
         running = RUNNING,
         dir = path2url(p.root()),
-        sep = path::SEP).as_slice()));
+        sep = old_path::SEP).as_slice()));
     assert_that(&p.release_bin("foo"), existing_file());
 });
 
index e9279d8eb4cfdef8ffc802eac46c6dfa7753b79b..21b690864d15c29965097cd55c6bd5460aa44362 100644 (file)
@@ -1,4 +1,4 @@
-use std::path;
+use std::old_path;
 use std::str;
 
 use support::{project, execs, basic_bin_manifest, basic_lib_manifest};
@@ -148,7 +148,7 @@ test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured
 
 ",
         COMPILING, p.url(), RUNNING,
-        sep = path::SEP))
+        sep = old_path::SEP))
               .with_stderr(format!("\
 thread '<main>' panicked at 'Some tests failed', [..]
 
index c2a4f6780cbdc91b976a33bb2a037069ede2a151..1ab15c83e99d546bef2bed46740bb64339d711b9 100644 (file)
@@ -1,5 +1,5 @@
 #![deny(warnings)]
-#![feature(collections, core, io, os, path, rustc_private, std_misc)]
+#![feature(collections, core, io, os, path, rustc_private, std_misc, env)]
 
 extern crate cargo;
 extern crate flate2;